<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<%@ include file="common.jsp"%>
		<link href="${ctx}/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css"/>
		<title>管理端</title>
	</head>

	<body>
		<div class="header" style="font-size: 25px;color: #fff;padding-top: 15px;"></div>
		<div class="loginWraper">
		    <div id="loginform" class="loginBox">
		        <form class="form form-horizontal">
		            <div class="row cl">
		                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
		                <div class="formControls col-xs-8">
		                    <input id="name"  type="text" placeholder="账号" required="true" class="input-text size-L">
		                </div>
		            </div>
		            <div class="row cl">
		                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
		                <div class="formControls col-xs-8">
		                    <input id="password"  type="password" placeholder="密码" required="true" class="input-text size-L">
		                </div>
		            </div>
		            <div class="row cl">
		                <div class="formControls col-xs-8 col-xs-offset-3">
		                    <input name="code" class="input-text size-L" type="text" placeholder="验证码" id="code" style="width:235px;">
		                    <a href="javascript:;" id="codeSend" class="btn btn-primary radius size-L">获取验证码</a>
		                </div>
		            </div>
		            <div class="row cl">
		                <div class="formControls col-xs-8 col-xs-offset-3">
		                    <a href="javascript:;" id="submit" class="btn btn-success radius size-L" >登录</a>
		                </div>
		            </div>
		        </form>
		    </div>
		</div>
		<div class="footer">Copyright &copy;2016 FirstApp.Me</div>
		
		<script type="text/javascript">
			$(document).ready(function () {
				 $('#submit').click(function () {
					var name = $("#name").val();
					var password = $("#password").val();
					var code = $("#code").val();
					
					$.ajax({
						type : 'post',
						url : ctx + '/loginManage/login.do',
						data : {
							name : name,
							password : password,
							code : code
						},
						dataType : 'json',
						timeout : 30000,
						context : $('body'),
						success : function(data) {
							if (data.code == "ok") {
			                   layer.msg("登录成功!", {icon: 6, time: 1000}, function () {
			                   		layer_close();
			                   });
			                   window.location.href= ctx +"/index.html";
							} else {
								 layer.msg(data.msg, {icon: 5, time: 2000});
							}
						},
						error : function(xhr, type) {
							layer.msg('登录失败!', {icon: 5, time: 2000});
						}
					});
					  return false;
				 });
				 
				 $('#codeSend').click(function () {
					 	var name = $("#name").val();
					 	var password = $("#password").val();
						$.ajax({
							type : 'post',
							url : ctx + '/loginManage/sendEmailCode.do',
							data : {
								name : name,
								password : password
							},
							dataType : 'json',
							timeout : 30000,
							context : $('body'),
							success : function(data) {
								if (data.code == "ok") {
									 layer.msg('验证码已经发送到您的邮箱，请注意查收!', {icon: 6, time: 2000});
								} else {
									layer.msg(data.msg, {icon: 5, time: 2000});
								}
							},
							error : function(xhr, type) {
								layer.msg('操作失败!', {icon: 5, time: 2000});
							}
						});
				 });
			});
		</script>
	</body>
</html>